package com.example.ana.aop.annotation;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.util.Arrays;

/**
 * @author hejianglong
 * @date 2019/11/14
 */
@Aspect
@Component
public class AdviceExample {

    @Around("com.example.ana.aop.annotation.SystemArchitecture.businessService()")
    public void beforeService(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("service 调用开始: " + Arrays.toString(pjp.getArgs()));
        pjp.proceed();
        System.out.println("service 调用结束");
    }

    @After("execution(* com.example.ana.service.impl.UserServiceImpl.queryUser(..))")
    public void afterQuery() {
        System.out.println("after query");
    }
}
